#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXN = 4e6+7;
LL cnt[MAXN];
LL a[MAXN], b[MAXN];

int main() {
#ifdef hai
    //freopen("in.txt", "r", stdin);
#endif
    LL n,m;
    LL k;
    scanf("%lld %lld", &n, &m);
    for (LL i=0; i<n; ++i) {
        scanf("%lld", &k);
        ++cnt[k];
    }
    a[0] = cnt[0];
    for (LL i=1; i<MAXN; ++i) {
        a[i] = cnt[i] + a[i-1];
    }
    LL res = 0;
    for (LL i=1; i<MAXN; ++i) {
        LL t = cnt[i];
        for (LL j=1; i*j<=m; ++j) {
            b[i*j] += t;
        }
    }
    for (LL i=1; i<=m; ++i) {
        b[i] += b[i-1];
    }
    for (LL x=1; x<=m; ++x) {
        LL cnt = b[x];
        for (LL t=1; t*x+x-1<MAXN; ++t) {
            LL cc = a[t*x+x-1] - a[t*x-1];
            cnt += (cc * t);
        }
        res ^= cnt;
    }
    printf("%lld\n", res);
    return 0;
}
